function thisrender(this, varargin)
%RENDER Render the Sampling Frequency Specifier

%   Author(s): J. Schickler
%   Copyright 1988-2004 The MathWorks, Inc.
%   $Revision: 1.10.4.5 $  $Date: 2004/12/26 22:21:28 $

frpos = parserenderinputs(this, varargin{:});

sz   = gui_sizes(this);
bgc  = get(0,'defaultuicontrolbackgroundcolor');
hFig = get(this,'FigureHandle');
cbs  = siggui_cbs(this);

if isempty(frpos), frpos = [10 10 160 sz.uh*3+sz.uuvs]*sz.pixf; end

% Title Position
pos = [frpos(1) frpos(2)+frpos(4)-sz.uh frpos(3)-sz.hfus sz.uh];

h.fstitle = uicontrol(hFig,...
    'Style',              'text',...
    'Position',           pos,...
    'Visible',            'Off',...
    'string',             'Sampling Frequency:',...
    'Tag',                'fsspecifier_title',...
    'HorizontalAlignment','left');

% Label Position
pos(3) = 31*sz.pixf;
pos(2) = pos(2)-sz.uh;

h.units_lbl = uicontrol(hFig,...
    'Style',               'text',...
    'Position',            pos,...
    'Visible',             'Off',...
    'string',              'Units:', ...
    'Tag',                 'fsspecifier_popup_lbl',...
    'HorizontalAlignment', 'right');

pos(2) = pos(2) - sz.uh - sz.uuvs;
h.value_lbl = uicontrol(hFig,...
    'Style',               'text',...
    'Position',            pos,...
    'Visible',             'Off',...
    'string',              'Fs:',...
    'Tag',                 'fsspecifier_editbox_lbl',...
    'HorizontalAlignment', 'right');

pos    = get(h.units_lbl, 'Position');
pos(1) = pos(1)+pos(3)+sz.uuhs;
pos(3) = 113*sz.pixf;

if pos(3) + pos(1) > frpos(1)+frpos(3)
    pos(3) = frpos(3)-pos(1)+frpos(1);
end

h.units = uicontrol(hFig, ...
    'Style',           'popup', ...
    'BackgroundColor', 'White', ...
    'Position',        pos,...
    'String',          set(this,'Units'), ...
    'Tag',             'fsspecifier_popup', ...
    'Visible',         'Off', ...
    'Callback',        {cbs.property, this, 'units', 'change Fs units'});

% Edit box position
pos(2) = pos(2) - sz.uh - sz.uuvs;

h.value = uicontrol(hFig,...
    'style',               'edit',...
    'BackgroundColor',     'white',...
    'Position',            pos,...
    'tag',                 'fsspecifier_editbox',...
    'Visible',             'Off',...
    'String',              this.Value,...
    'HorizontalAlignment', 'left',...
    'callback',            {cbs.property, this, 'value', 'change Fs'});

set(this,'Handles',h)

wrl = handle.listener(this, [this.findprop('Units') this.findprop('Value')], ...
        'PropertyPostSet', @lclprop_listener);
set(wrl,'CallbackTarget',this);
set(this,'WhenRenderedListeners',wrl);

prop_listener(this, 'units');

setupenablelink(this, 'units', {'hz', 'khz','mhz','ghz'}, 'value');

% -------------------------------------------------------------------------
function lclprop_listener(this, eventData)

prop_listener(this, eventData);

% [EOF]
